package com.chx.mapper;

import com.chx.annotation.AutoFill;
import com.chx.dto.CustomerPageQueryDto;
import com.chx.entity.Customers;
import com.chx.enumeration.OperationType;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author cp-月入过万
 * @Date 2025/5/30
 */
@Mapper
public interface CustomerMapper {
    @Insert("insert into customers (customer_name,contact_person,phone,address,email,description,create_time,update_time) " +
            "values " +
            "(#{customerName},#{contactPerson},#{phone},#{address},#{email},#{description},#{createTime},#{updateTime})")
    @AutoFill(OperationType.INSERT)
    void insert(Customers customers);

    @AutoFill(OperationType.UPDATE)
    void update(Customers customers);

    @Select("select * from customers where customer_id = #{id}")
    Customers getById(Long id) ;

    Page<Customers> pageQuery(CustomerPageQueryDto customerPageQueryDto) ;

    @Select("select * from customers")
    List<Customers> getAllCustomers();
}
